import QtQuick 2.4
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.0

Rectangle {
    id: root
    anchors.fill: parent
    color: "lightblue"
    property alias buttonSet: buttonSet

    property var target : null
    property alias name: name
    property alias dial: dial
    width: 400
    height: 350

    ColumnLayout {
        id: column
        width: root.width

        Label {
            id: label
            text: qsTr("Enter a name:")
        }

        TextField {
            id: name
            width: parent.width
            text: "Cat"
            Layout.fillWidth: true
        }

        RowLayout {
            id: row
            width: root.width
            Layout.fillHeight: true
            Layout.fillWidth: true

            Dial {
                id: dial
                Layout.fillHeight: true
                Layout.fillWidth: true
            }
        }



        RowLayout {
            id: row2
            height: 40
            Layout.fillHeight: true
            Layout.fillWidth: true
            width: root.width
            Button {
                id: buttonSet
                text: "set name"
                Layout.fillWidth: true
                onClicked: {
                    console.log(" MyRectangle.buttonSet.onClicked() name =[", name.text, "]")
                    if (target) target.text = name.text
                }
            }

            Button {
                id: buttonHide
                text: "hide only"
                Layout.fillWidth: true
                onClicked:{
                    console.log(" MyRectangle.buttonHide.onClicked()")
                    root.visible= false;
                    root.parent = null
                }
            }

            Button {
                id: buttonDestroy
                text: "destroy"
                Layout.fillWidth: true
                onClicked:{
                    console.log(" MyRectangle.buttonDestroy.onClicked()")
                    root.destroy()
                }
            }
        }

     }
}


